package com.yh.util;

import java.util.List;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

public class JsonUtil {

	private static  Gson json = new Gson();
	
	public static String  toJsonString(Object object) 	{
		String jsonString = json.toJson(object);
		
		return jsonString;
	}
	
	public static Object toObject(String jsonString){
		
		
		Object object = json.fromJson(jsonString, Object.class);
		
		return object;
	}
	
	public static List<Object> toObjectList(String jsonString){
		
		List<Object> objectList = json.fromJson(jsonString, new TypeToken<List<Object>>(){}.getType());
		return objectList;
	}
	
}
